import Vue from 'vue'
import Vuex, {StoreOptions} from 'vuex'
import UserInfo from "@/common/UserInfo"

Vue.use(Vuex)

interface RootState {
    userInfo?: UserInfo;
}

const store: StoreOptions<RootState> = {
    state: {
        userInfo: undefined
    },
    mutations: {
        setUserInfo(state, userInfo) {
            state.userInfo = userInfo
        },
        clearUserInfo(state) {
            state.userInfo = undefined
            localStorage.clear()
        }
    },
    actions: {},
    modules: {}
}


export default new Vuex.Store<RootState>(store)